package ua.kpi_java_training.tyshchenko.module2.test;

import static junit.framework.Assert.*;
import org.junit.Before;
import org.junit.Test;
import ua.kpi_java_training.tyshchenko.module2.*;


/**
 * @author Vlad Tyshchenko
 * @version 1.0 5 June 2013
 */
public class PositionTest {
    AbstractInputAllData allData;
    Position pos;
    Habitat habitat;

    @Before
    public void setUp() {
        allData = new StabInputAllData();
        pos = new Position(new StabRandom(), new Habitat(allData));
        habitat = new Habitat(allData);
    }

    @Test
    public void testAddWidth() {
        int coordinateX = pos.getWidth();
        pos.addCoordinateX(1);
        assertEquals("added coordinateX ", coordinateX + 1, pos.getWidth());
        pos.addCoordinateX(100);
        assertEquals("boundary conditions added coordinateX creature ", coordinateX + 1, pos.getWidth());

    }

    @Test
    public void testAddLength() {
        int coordinateY = pos.getLength();
        pos.addCoordinateY(1);
        assertEquals("added coordinateY ", coordinateY + 1, pos.getLength());
        pos.addCoordinateY(100);
        assertEquals("boundary conditions added coordinateY creature ", coordinateY + 1, pos.getLength());

    }

    @Test
    public void testRobWidth() {
        int coordinateX = pos.getWidth();
        pos.robCoordinateX(1);
        assertEquals("rob coordinateX ", coordinateX - 1, pos.getWidth());
        pos.robCoordinateX(100);
        assertEquals("boundary conditions rob coordinateX creature ", coordinateX - 1, pos.getWidth());
    }

    @Test
    public void testRobLength() {
        int coordinateY = pos.getLength();
        pos.robCoordinateY(1);
        assertEquals("rob coordinateY ", coordinateY - 1, pos.getLength());
        pos.robCoordinateY(100);
        assertEquals("boundary conditions rob coordinateY creature ", coordinateY - 1, pos.getLength());
    }

    @Test
    public void testEquals() {
        assertFalse("equals false ", pos.equals(new Position(habitat)));
        assertTrue("equals true ", pos.equals(new Position(new StabRandom(), habitat)));
    }

    @Test
    public void testClone() {
        assertTrue("create clone ", pos.equals(pos.clone()));
    }

}
